<!-- 中英文切换 -->
<template>
   <el-select v-model="value" class="m-2" size="small" @change="changes">
      <el-option v-for="item in options" :key="item.value" :label="item.value" :value="item.text"
         :disabled="value == item.text" />
   </el-select>
</template>
<script setup lang="ts">
import { ref, reactive } from 'vue'
import { useI18n } from "vue-i18n"
const value = ref(localStorage.getItem('language'))//获取本地储存防止刷新回到默认选项
const options = reactive([
   { value: '中文', text: 'zn' }, { value: 'English', text: 'en' }
])
let { locale } = useI18n()
let emit=defineEmits(['setLanguage'])
const changes = (val: string) => {
   value.value = val
   locale.value = val
   localStorage.setItem('language', val)
   emit('setLanguage')
}
</script>
<style scoped lang="less">
.m-2 {
   width: 100px;
}
</style>